<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
<!-- 引入 layui.css -->
<link rel="stylesheet" th:href="@{/css/layui.css}">
 
<!-- 引入 layui.js -->
<script th:src="@{/layui.js}"></script>
 
<style>
    #center{
        padding-left: 10%;
        padding-right: 10%;
    }
</style>


</head>
<body id="center">
   <!-- 示例-970 -->
<ins class="adsbygoogle" style="display:inline-block;width:970px;height:90px" data-ad-client="ca-pub-6111334333458862" data-ad-slot="3820120620"></ins>
  
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>后台管理系统</legend>
</fieldset>
 
<form method="post" class="layui-form" th:action="@{/user/login}" lay-filter="example">
  <div class="layui-form-item">
    <label class="layui-form-label">账号：</label>
    <div class="layui-input-block">
      <input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="请输入账号" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码：</label>
    <div class="layui-input-block">
      <input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
    </div>
  </div>


 
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="button" class="layui-btn layui-btn-normal" id="LAY-component-form-setval">赋值</button>
      <button type="button" class="layui-btn layui-btn-normal" id="LAY-component-form-getval">取值</button>
      <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">登录</button>
      &nbsp;&nbsp;<span style="color: red" th:text="${mag}"></span>
    </div>
  </div>
</form>



<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script>
    layui.use(['form'], function(){
      var form = layui.form

      //表单赋值
      layui.$('#LAY-component-form-setval').on('click', function(){
        form.val('example', {
          "username": "雁迟" // "name": "value"
          ,"password": "123456"
        });
      });
      
      //表单取值
      layui.$('#LAY-component-form-getval').on('click', function(){
        var data = form.val('example');
        alert(JSON.stringify(data));
      });
      
    });
    </script>

</body>
</html>